<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //main 本意有入口的意思
      async function main() {
        let p = new Promise((resolve, reject) => {
          setTimeout(() => {
            // resolve("OKOK");
            reject('Error');
          }, 2000);
        });

        try {
          let res = await p; // await async 异步   wait 等待
          console.log(res);
        } catch (e) {
          console.warn(e);
        }

        // let res = await 200;
        // console.log(res);
      }

      main();
    </script>
  </body>
</html>
